<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<!DOCTYPE html>
<html>
  <head>
    <title>用户管理</title>
    <script type="text/javascript" src="/assets/layer-v2.0/layer/layer.js"></script>
    <script type="text/javascript">
    	function deleteUser(code){
    		//询问框
    		layer.confirm('确定删除该用户吗？', {
    		    btn: ['确定','取消'] //按钮
    		}, function(){
    			post("/user/deleteUser",{code:code},function(data){
    				layer.msg(data.result, {icon: 1});
    			});
    		}, function(){
    			return;
    		});
    	}
    </script>
  </head>
  <body>
	<section class="content-header">
         <h1>
          	 用户管理
         </h1>
         <ol class="breadcrumb">
           <li><a href="#"><i class="fa fa-dashboard"></i> 用户管理</a></li>
           <li class="active">用户列表</li>
         </ol>
     </section>
     <section class="content">
     	<div class="row">
	     	<div class="col-md-12">
	     	    <!-- 第一块 -->
		     	<div class="box box-primary">
		     		<div class="box-header with-border">
					   <a href="/role/toRoleUpdate" class="btn bg-olive btn-flat margin">添  加</a>
					</div>
		     	</div>
		     	<!-- 第二块 -->
		     	<div class="box box-danger">
		     		<div class="box-body">
		     			<div class="row">
				     		<form class="form-inline" action="/user/userList" name="userForm" method="post">
							  <div class="col-xs-3">
							    <label for="inputName2">账号</label>
							    <input type="text" name="account" class="form-control" id="inputName2" >
							  </div>
							  <button type="submit" class="btn btn-default"><i class="fa fa-fw fa-search"></i>查 询</button>
							</form>
						</div>
					</div>
		     	</div>
		     	<!-- 第仨块 -->
	     	 	<div class="box box-success">
		     		<div class="box-header with-border">
	                  <h3 class="box-title">查询结果</h3>
	                </div><!-- /.box-header -->
	                <div class="box-body">
	                  <table id="example2" class="table table-bordered table-hover">
	                    <thead>
	                      <tr>
	                        <th>编号</th>
	                        <th>姓名</th>
	                        <th>账号</th>
	                        <th>手机号</th>
	                        <th>状态</th>
	                        <th>操作</th>
	                      </tr>
	                    </thead>
	                    <tbody>
	                      <c:forEach var="item" items="${userList }" varStatus="status">
	                      	  <tr>
		                        <td>${status.index+1 }</td>
		                        <td>${item.name }</td>
		                        <td>${item.account }</td>
		                        <td>${item.mobile }</td>
		                        <td>
		                        	<c:if test="${item.state ==0 }">正常</c:if>
		                        	<c:if test="${item.state !=0 }">停用</c:if>
		                        </td>
		                        <td>
		                        	<button type="button" onclick="window.location.href='/user/toUserUpdate?code=${item.code}&flag=update'" class="btn btn-warning">修改</button>
		                        	<button type="button" onclick="deleteUser('${item.code}')" class="btn btn-danger">删除</button>
		                        </td>
		                      </tr>
	                      </c:forEach>
	                    </tbody>
	                  </table>
	                </div>
	     		</div>
	       	</div>
     	</div>
     </section>
  </body>
</html>
